#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
int main()
{
    int ret;
    struct rlimit rlim;

    /* Get the core dump limitation */
    ret = getrlimit(RLIMIT_CORE, &rlim);
    printf( "RLIMIT_CORE returned %d (%lu, %lu)\n", ret, rlim.rlim_cur, rlim.rlim_max );

    /* Set the core dump limitation to be unlimited */
    rlim.rlim_cur = RLIM_INFINITY;
    rlim.rlim_max = RLIM_INFINITY;
    ret = setrlimit(RLIMIT_CORE, &rlim);
    printf("RLIMIT_CORE returned %d\n", ret );

    /* Get the core dump limitation again */
    ret = getrlimit(RLIMIT_CORE, &rlim);
    printf( "RLIMIT_CORE returned %d (%lu, %lu)\n", ret, rlim.rlim_cur, rlim.rlim_max );
    return 0;
}
